#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <stdlib.h>





int removeElement(int* nums, int numsSize, int value)
{	
	int position = 0;
	for (; position < numsSize; position++)
	{
		if (nums[position] == value)
		{
			while (nums[numsSize-1] == value)
			{
				numsSize--;
			}
			if (position <= numsSize - 1)
			{
				nums[position] = nums[numsSize - 1];
				numsSize--;
			}
			else
			{
				return numsSize;
			}
		}
	}
	return numsSize;
}	


int main()
{
	int nums[] = { 2,3,5,3,4,5,5,8};
	int size=removeElement(nums,sizeof(nums)/sizeof(int), 5);
	printf("%d\n", size);
	for (int i=0; i <size; i++)
	{
		printf("%d ", nums[i]);
	}
	return 0;
}




	
